import React from 'react';
import { StyleSheet } from 'react-native';
import { TouchableOpacity, TouchableOpacityProps } from 'react-native';

// 封装TouchableOpacity组件，可以更改透明度等
// React.memo表示相当于class组件的prueComponent的优化
const Touchable: React.FC<TouchableOpacityProps> = 
React.memo(({ style, ...rest}) => {
    const touchTableStyle = rest.disabled ? [style, styles.disabled] : style 
    return (
        <TouchableOpacity activeOpacity={0.8} style={ touchTableStyle } {...rest}/>
    )
})
const styles = StyleSheet.create({
    disabled: {
        opacity: 0.5
    }
})
export default Touchable;